<?php
	/**
	 * 检测是否有福利可领
	 */
    class CheckWelfare extends APIBase {
		
		public $tag = "CheckWelfare";
		public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}

		public function logic() {
			$uid = $this->uid;
			$time = time();
			$flag = 0;//1表示有红点
			//获取领取救济金的次数
			$list = $this->data_redis->hMGet("hu:{$uid}",array('benefit_cnt','money'));
			//获取今天用户是否有签到
			$is_sign = $this->cache_redis->hGet("hSign:{$uid}",'is_sign');
		
			$benefit_cnt = (int)$list['benefit_cnt'];
			$money = (int)$list['money'];
			if(($benefit_cnt < Game::$broke_num_max && $money < Game::$broke_money) || (int)$is_sign==0){
				$flag = 1;
			}
			$this->returnData(array("flag"=>$flag));
		}
		
    	public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
